package nineteen;

import java.util.Random;

/**
 * 从enum实例中随即选取
 *
 * @author sun.ye
 * @since 2020-05-02 08:43
 */
public class Enums {

    private static Random random = new Random(47);
    public static <T extends Enum<T>> T random(Class<T> ec){
        return random(ec.getEnumConstants());
    }

    public static <T> T random(T[] values){
        return values[random.nextInt(values.length)];
    }
}